﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using net_ddns_server_ali;
using net_ddns_server_ali.Code;

class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args)
    {
        return Host.CreateDefaultBuilder(args)
             .ConfigureServices((serviceProvider) => {
                 var log = new NewConsoleLog("aliDDNS");
                 log.Info($"aliDDNS v{typeof(DomainIPSyncService).Assembly.GetName().Version} 作者 lanhuxing@lanhuxing.cn");

                 string configFile = "~/aliyun.ddns.config.json";

                 DomainIPSyncService ddns = new(configFile) { Log = log };

                 serviceProvider
                    .AddSingleton<ILog>(log)
                    .AddSingleton(ddns);

                 log.Info($"配置文件:{configFile}");

                 ddns.Start();
             });
    }
}